// 纹理管理器
// 这是一个单例类

#ifndef ALICE_GRAPHICS_TEXTURE_MANAGER_H_
#define ALICE_GRAPHICS_TEXTURE_MANAGER_H_

#include <unistd.h>

#include <map>
#include <cstring>

#include <SDL.h>
#include <SDL_image.h>

#include "director.h"

namespace alice {

class TextureManager {
  public:
    static TextureManager* GetInstance() {
      return instance_ = (instance_ == nullptr ? new TextureManager() : instance_); 
    }

    bool Load(std::string id, std::string filename);
    void Draw(std::string id, int x, int y, int w, int h, SDL_RendererFlip flip=SDL_FLIP_NONE);
    void DrawFrame(std::string id, int x, int y, int w, int h, int row, int frame, SDL_RendererFlip flip=SDL_FLIP_NONE);
    void DrawTile(std::string id, int x, int y, int tile_size, int row, int frame, SDL_RendererFlip flip=SDL_FLIP_NONE);
    void Drop(std::string id);
    void Clean();

  private:
    TextureManager() {  }

  private:
    static TextureManager* instance_;
    std::map<std::string, SDL_Texture*> texture_map_;
};

}

#endif // ALICE_GRAPHICS_TEXTURE_MANAGER_H_
